<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
		<script src="crypto-js.js"></script>
		<script>
			function test_m(){
				alert(1)
			}
			
			var aesKey = "46cc793c53dc451b"
			/*字符加密*/
			function encryptRequest(word) {
			    /*公共秘钥，这边先写死*/
			    let key = CryptoJS.enc.Utf8.parse(aesKey);
			    let srcs = CryptoJS.enc.Utf8.parse(word);
			    let encrypted = CryptoJS.AES.encrypt(srcs, key, {
			        mode: CryptoJS.mode.ECB,
			        padding: CryptoJS.pad.Pkcs7
			    });
			    return encrypted.toString();
			}
			
			/*解密方法*/
			function decryptRequest(word) {
			    /*公共秘钥，这边先写死*/
			    let key = CryptoJS.enc.Utf8.parse(aesKey);
			    let decrypt = CryptoJS.AES.decrypt(word, key, {
			        /*以下两个属性需要和加密对应*/
			        mode: CryptoJS.mode.ECB,
			        padding: CryptoJS.pad.Pkcs7
			    });
			    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
			}
			
			var text = "hello";
			console.log("加密字符：", text);
			console.log("加密后字符：",encryptRequest(text))
			console.log("解密后字符：",decryptRequest(encryptRequest(text)))
			
			var str = "O5jmrfkrys6Ps0x2fIX4bDYBiKIYDx5e7r68MRYtz3RLxEKmHwQ5XLbQzmZkId7nsvWEjdcIIRBf3hoD4CV53/c1jd1PBwioRMXUar+rq9ntIBjC5WexsqfeBdKUnFI80JWUstox5y7hPLpE4ndj8QwMeHq+L19Qe2iOBwiF1MYBTk67M6NCJy7meBpYv+GyYEHxaFT5OgTm2Eb0tzTktg=="
			console.log("解密后字符：",decryptRequest(str))
		</script>
	</head>
	<body>
		<h2>crypto 学习Demo</h2>
		<video width="640" height="360"
		        autoplay controls autobuffer 
		        src="https://free.yunkecom.com/free/MF203FGV/MF203FGV.m3u8?sign=925e78ddcb0ec6780b3bcf3a128073c1&t=1603898711"
		        type="application/vnd.apple.mpegurl">
		</video>
	</body>
</html>
